<?php


namespace app\http\middleware;


use think\facade\Env;
use think\facade\Request;

class checkEncry
{
    public function handle($request, \Closure $next)
    {
        $encryptString = Request::param('encrypt');
        if (empty($encryptString)) {
            return pxsFailedJson("请传入正确encrypt");
        }
        $key =  Env::get("MOBILE.KEY");
        $time = decrypt($encryptString,$key);
        if (time() - $time > 3600){
            return pxsFailedJson("encrypt 已超时");
        }
        $arr["staff_no"] = "PXS00000";
        $arr["staff_name"] = "铺先生";
        $request->_user = $arr;
        return $next($request);
    }
}